import { Entity, ManyToOne, PrimaryKey, Property } from "@mikro-orm/core";
import { BaseEntity } from "./Base";
import { Author } from "./Author";

@Entity()
export class Book extends BaseEntity {
    @Property({ unique: true })
    title: string;

    @Property({ length: 100 })
    intro!: string;

    @ManyToOne({ entity: () => Author, nullable: true })
    author?: Author;

    constructor(title: string, intro: string) {
        super();
        this.title = title;
        this.intro = intro;
    }
}
